#!/bin/bash
set -e

# Set debug mode
set -x
set -v

if [[ $TRAVIS_PYTHON_VERSION -gt 30 ]]; then
  export CMAKE_ADDITIONAL_OPTIONS=" ${CMAKE_ADDITIONAL_OPTIONS} -DPYTHON_EXECUTABLE=$(which python3)"
fi

export CMAKE_ADDITIONAL_OPTIONS=" ${CMAKE_ADDITIONAL_OPTIONS} -DBUILD_BENCHMARK=\"ON\" -DBUILD_TESTING=\"ON\" -DCMAKE_CXX_FLAGS=-DBOOST_SYSTEM_NO_DEPRECATED"
if [[ ";${DO_INSTALL_DOC_EXCEPT_ON_BRANCH};" == *";${CI_BRANCH};"* ]]; then
  export CMAKE_ADDITIONAL_OPTIONS=" ${CMAKE_ADDITIONAL_OPTIONS} -DINSTALL_DOCUMENTATION=\"OFF\""
else
  export CMAKE_ADDITIONAL_OPTIONS=" ${CMAKE_ADDITIONAL_OPTIONS} -DINSTALL_DOCUMENTATION=\"ON\""
fi
export CMAKE_ADDITIONAL_OPTIONS="${CMAKE_ADDITIONAL_OPTIONS} -DDISABLE_DEPRECATED_MACRO_WARNING=\"ON\""
export CMAKE_ADDITIONAL_OPTIONS="${CMAKE_ADDITIONAL_OPTIONS} -DCMAKE_CXX_FLAGS_DEBUG=\"-O1\""
export PKG_CONFIG_PATH="${PKG_CONFIG_PATH}:/opt/openrobots/lib/pkgconfig"
export LD_LIBRARY_PATH="${LD_LIBRARY_PATH}:/opt/openrobots/lib"
export PYTHONPATH="${PYTHONPATH}:/opt/openrobots/lib/python${TRAVIS_PYTHON_VERSION_WITH_DOT}/site-packages"
export MAKEFLAGS="-j2"

# Setup environment variables.
./.travis/run ../.travis/build

# End debug mode
set +v
set +x
